import com.zhangrui.dao.TeacherMapper;
import com.zhangrui.pojo.Teacher;
import com.zhangrui.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;
import org.junit.Test;

import java.util.List;

/**
 * ClassName:Text
 * Package:PACKAGE_NAME
 * Description:
 *
 * @Date:2021/8/2422:30
 * @Author:zhangrui@qq.com
 */
public class Text {
    Logger logger = Logger.getLogger(Text.class);

/*    @Test
    public void text1() {
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        TeacherMapper teacherMapper = sqlSession.getMapper(TeacherMapper.class);
        List<Teacher> teacherList = teacherMapper.getTeacher();
        for (Teacher teacher : teacherList) {
            logger.info(teacher);

        }
        sqlSession.close();
    }*/

    @Test
    public void test2() {
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        TeacherMapper teacherMapper = sqlSession.getMapper(TeacherMapper.class);
//        按照结果集嵌套处理
//        Teacher teacher = teacherMapper.getTeacher(1);
//        子查询处理
        Teacher teacher = teacherMapper.getTeacher2(1);
        logger.info(teacher);
        sqlSession.close();
    }
}
